package com.neteast.androidclient.contact.domain;

import com.neteast.androidclient.contact.Constant;


public class ContactData implements Comparable<ContactData> {
	
	//用于服务器
	public int id;
	//用于本地数据库
	public int localId;
	public String label;
	public String content;
	public boolean isReadOnly=false;
	public int modified=Constant.CONTACT_NEW;
	public int mimeTypeId;

	

	@Override
	public String toString() {
		return "ContactData [id=" + id + ", localId=" + localId + ", label="
				+ label + ", content=" + content + ", isReadOnly=" + isReadOnly
				+ ", modified=" + modified + ", mimeTypeId=" + mimeTypeId + "]";
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactData other = (ContactData) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (id != other.id)
			return false;
		if (isReadOnly != other.isReadOnly)
			return false;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		if (mimeTypeId != other.mimeTypeId)
			return false;
		if (modified != other.modified)
			return false;
		return true;
	}



	@Override
	public ContactData clone(){
		ContactData data=new ContactData();
		data.id=id;
		data.localId=localId;
		data.label=label;
		data.content=content;
		data.isReadOnly=isReadOnly;
		data.modified=modified;
		data.mimeTypeId=mimeTypeId;
		return data;
	}

	public int compareTo(ContactData another) {
		if(this.isReadOnly&&another.isReadOnly){
			return this.id-another.id;
		}else if (this.isReadOnly) {
			return -1;
		}else {
			return 1;
		}
	}
}
